package com.topone.permission.sercurity.service;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;
import org.springframework.stereotype.Component;

import com.topone.permission.utils.ControllerUtils;

/**
 *  自定义session过期策略
 * @author XiaZhentao
 * @date 2018年12月1日
 */
@Component("mySessionInformationExpiredStrategy")
public class MySessionInformationExpiredStrategy implements SessionInformationExpiredStrategy {
	
	@Override
	public void onExpiredSessionDetected(SessionInformationExpiredEvent eventØ) throws IOException, ServletException {
		  	HttpServletResponse response = eventØ.getResponse();
		    HttpServletRequest  request = eventØ.getRequest();
		    ControllerUtils.failedRepose(request, response, "5001", "重新登录");
	}

}
